<template>
  <view>
    <view :style="'--color:' + color + ';'" class="hid_top">
      <view :style="'background-image:url(' + bg + ');'" class="bg"></view>
      <image :src="D.path_b_url" class="logo" mode="aspectFill"></image>
      <view class="truename">
        <text class="h2">{{ D.title }}</text>
        <view class="title ico"> {{ D.areatitle }}</view>
      </view>
      <view class="myb ico"> {{ D.worktime }}</view>
    </view>
    <view :style="'--rgbcolor:' + rgbcolor + ';'" class="hn_i_box aboutus">
      <view class="h1">
        {{ D.content_t }}
        <text class="b"></text>
      </view>
      <rich-text :nodes="D.content" class="C"></rich-text>
    </view>
    <view v-if="HN.length > 0" :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="hn_i_box hnlist">
      <view class="h1">
        {{ D.hn_t }}
        <text class="b"></text>
      </view>
      <navigator v-for="(item, index) in HN" :key="index" :url="'/hnPages/hn_detail/hn_detail?id=' + item.id"
                 class="li" hoverClass="none">
        <image :src="item.path_b_url" mode="aspectFill"></image>

        <view class="h2">{{ item.truename }}</view>

        <view class="h4">{{ item.title }}</view>

        <view class="span add">
          <text class="i ico"></text>
          找{{ item.sex_title }}牵线
        </view>
      </navigator>
    </view>
    <view v-if="D.tel != '' || D.weixin != '' || D.ewm != '' || D.address != ''"
          :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';'"
          class="hn_i_box contact_box">
      <view class="h1">
        {{ D.contact_t }}
        <text class="b"></text>
      </view>
      <view class="dl">
        <view class="dt">
          <view v-if="D.tel != ''" class="li" @tap="telFn">
            <text class="p ico telico"></text>
            热线
            <text class="span">{{ D.tel }}</text>
          </view>
          <view v-if="D.weixin != ''" class="li">
            <text class="p ico wxico"></text>
            微信
            <text class="span">{{ D.weixin }}</text>
          </view>
          <view v-if="D.address != ''" class="li">
            <text class="p ico addressico"></text>
            地址
            <text class="span">{{ D.address }}</text>
          </view>
        </view>
        <view class="dd">
          <view class="hnewm">
            <image :showMenuByLongpress="true" :src="D.ewm" mode="aspectFill"></image>
            <text class="h6"></text>
          </view>
        </view>
      </view>
    </view>
    <view id="anlibox" :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';'" class="hn_i_box">
      <view class="h1">
        {{ D.anli_t }}
        <text class="b"></text>
      </view>
      <view class="anli">
        <block v-if="ANLI.length > 0">
          <view v-for="(item, index) in ANLI" :key="index" class="li">
            <view class="a">
              <image :src="item.photo_s" mode="aspectFill"></image>
              <view class="h5">{{ item.nickname }} {{ item.age }}</view>
            </view>
          </view>
        </block>
        <view v-else class="nodata">
          <image mode="aspectFit" src="/static/res/img/nodata.png"></image>
          暂时还木有
        </view>
      </view>
    </view>
    <view :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="nextbtn">
      <button class="btn44 ico" @tap="aidFn">{{ D.sitebtn }}</button>
    </view>
    <view class="blank"></view>
  </view>
</template>
<script>
var t;
var a = require('../../res/www.a9a.cn.js');
var app = getApp();
export default {
  data() {
    return {
      mask_class: 'alpha0_100',
      bg: app.globalData.WWW + '/res/m/img/my_bg.png',
      id: '',
      color: '',
      rgbcolor: '',

      D: {
        path_b_url: '',
        title: '',
        areatitle: '',
        worktime: '',
        content: '',
        tel: '',
        weixin: '',
        ewm: '',
        address: '',
        sitebtn: ''
      },

      HN: '',
      ANLI: '',
      div_bbs: false,
      div_login: false,
      ifagree: false
    };
  },
  onLoad: function (t) {
    var that = this;
    var n = this;
    var e = t.id;
    n.setData({
      id: e
    });
    app.globalData.get_config('_ZEAI').then(function (t) {
      n.setData({
        color: app.globalData._ZEAI.color,
        rgbcolor: a.c16_rgb(app.globalData._ZEAI.color)
      });
      uni.setNavigationBarColor({
        backgroundColor: app.globalData._ZEAI.color,
        frontColor: '#ffffff'
      });
      uni.setBackgroundColor({
        backgroundColorTop: app.globalData._ZEAI.color
      });
    });
    app.globalData.get_openid().then(function (t) {
      that.init();
    });
  },
  onPullDownRefresh: function () {
    var that = this;
    uni.vibrateShort({
      type: 'heavy'
    });
    setTimeout(function () {
      uni.stopPullDownRefresh();
      that.init();
    }, 500);
  },
  onShareAppMessage: function () {
    return {
      imageUrl: this.D.path_s,
      title: this.D.truename,
      path: '/hnPages/agent/detail?id=' + this.id
    };
  },
  onShareTimeline: function () {
    return {
      imageUrl: this.D.path_s,
      title: this.D.truename,
      query: 'id=' + this.id,
      path: '/hnPages/agent/detail'
    };
  },
  methods: {
    init: function () {
      var that = this;
      uni.showLoading({
        title: '玩命加载中...',
        mask: true
      });
      uni.showNavigationBarLoading();
      t = uni.getStorageSync('COOK_U');
      app.globalData.ajax({
        url: 'agent.php',
        data: {
          submitok: 'detail',
          openid: t.openid,
          id: that.id
        },
        success: function (t) {
          if (1 == t.flag) {
            that.setData({
              D: t.D,
              HN: t.HN,
              ANLI: t.ANLI
            });
            uni.setNavigationBarTitle({
              title: t.D.sitetitle
            });
            uni.setBackgroundColor({
              backgroundColorTop: that.color
            });
          } else {
            uni.showToast({
              title: t.msg,
              icon: 'none',
              mask: true
            });
          }
          uni.hideLoading();
          uni.hideNavigationBarLoading();
        }
      });
    },

    aidFn: function (t) {
      a.set_options_aid(this, {
        aid: this.id
      });
      uni.switchTab({
        url: '../index/index4'
      });
    },

    telFn: function (t) {
      uni.makePhoneCall({
        phoneNumber: this.D.tel
      });
    },

    bbs_addFn: function () {
      var that = this;
      app.globalData.chklogin().then(function (a) {
        if (a) {
          that.setData({
            div_bbs: true
          });
        } else {
          uni.redirectTo({
            url: '/pages/login/login'
          });
        }
      });
    },

    back: function () {
      this.setData({
        div_login: false
      });
    },

    kefu_closeFn: function () {
      this.setData({
        div_bbs: false
      });
    },

    anliFn: function () {
      a.o('#anlibox', function (t) {
        uni.pageScrollTo({
          scrollTop: t[0].top - 20,
          duration: 300
        });
      });
    },

    ifagreeFn: function (t) {
      1 == t.detail.value
          ? this.setData({
            ifagree: true
          })
          : this.setData({
            ifagree: false
          });
    },

    ifagree_passFn: function () {
      uni.showToast({
        title: '请先同意《用户协议》和《隐私条款》',
        icon: 'none',
        mask: true,
        duration: 3000
      });
    }
  }
};
</script>
<style>
@import 'detail.css';
</style>
